<template>
  <div>
    <div class="nav-top flex jc-sb">
      <div class="flex ai-c">
        <div class="nav-logo flex ai-c">
          <img src="../assets/backstage.png" alt="" />
        </div>
        <i style="color: #c0c4cc" class="el-icon-arrow-left"></i>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item v-for="it in $route.meta" :key="it">{{
              it
          }}</el-breadcrumb-item>
        </el-breadcrumb>
      </div>

      <div class="nav-login">
        <p class="user">{{ account }}</p>
        <p class="user cursor" @click="adddialogVisible = true">修改密码</p>
        <div class="login-out">
          <a href="#" @click="out()">退出</a>
        </div>
      </div>
    </div>
    <div class="flex">
      <div class="lef">
        <div class="nav-list">
          <el-menu router class="el-menu-demo" @select="handleSelect" text-color="#000" active-text-color="#FF5478">
            <el-menu-item class="shouye flex ai-c" index="/layout/index">
              <img class="shouimg" src="../assets/shouyeguanli.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <img class="shouactive" src="../assets/shouyeactive.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item class="shipin flex ai-c" index="/layout/videolist">
              <img class="shipinimg" src="../assets/shipinguanli.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <img class="shipinactive" src="../assets/shipiinactive.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <span slot="title">内容管理</span>
            </el-menu-item>
            <el-menu-item class="yonghu flex ai-c" index="/layout/userlist">
              <img class="yonghuimg" src="../assets/renyuanguanli.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <img class="yonghuactive" src="../assets/personactive.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <span slot="title">用户管理</span>
            </el-menu-item>

            <el-menu-item class="shuju flex ai-c" index="/layout/pointall">
              <img class="shujuimg" src="../assets/zuobiaoxiguanli.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <img class="shujuactive" src="../assets/quxiantuactive.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <span slot="title">数据管理</span>
            </el-menu-item>
            <el-menu-item class="xitong flex ai-c" index="/layout/Rolemanagement">
              <img class="xitongimg" src="../assets/shezhihuanli.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <img class="xitongactive" src="../assets/shezhiactive.png"
                style="width: 18px; height: 16px; margin-right: 10px" alt="" />
              <span slot="title">系统管理</span>
            </el-menu-item>
            <!-- <el-submenu index="/layout/videolist">
              
              <el-menu-item index="/layout/videolist">视频列表 </el-menu-item>
              <el-menu-item index="/layout/taglist">标签列表</el-menu-item>
              <el-menu-item index="/layout/classlist">分类列表</el-menu-item>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <span>用户管理</span>
              </template>

              <el-menu-item index="/layout/userlist">用户列表 </el-menu-item>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <span>数据管理</span>
              </template>
              <el-menu-item index="/layout/pointall"> 积分统计 </el-menu-item>
              <el-menu-item index="/layout/pointchange">
                积分变动记录
              </el-menu-item>
            </el-submenu>

            <el-submenu index="5">
              <template slot="title">
                <span>系统管理</span>
              </template>
              <el-menu-item index="/layout/Rotationsettings"
                >轮播设置</el-menu-item
              >
              <el-menu-item index="/layout/Rolemanagement"
                >角色管理</el-menu-item
              >
            </el-submenu> -->
          </el-menu>
        </div>
      </div>
      <div class="right">
        <transition name="custom-classes-transition" enter-active-class="animated fadeIn">
          <router-view />
        </transition>
      </div>
    </div>
    <el-dialog title="修改密码" center :visible.sync="adddialogVisible" width="445px">
      <div class="add-input">
        <el-form :model="passwordForm" ref="ruleForm" label-width="80px" class="demo-ruleForm">
          <el-form-item label="新密码" required>
            <el-input v-model="passwordForm.password" />
          </el-form-item>
          <el-form-item label="确认密码" required>
            <el-input v-model="passwordForm.confirmPassword" />
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="cancelbtn" @click="adddialogVisible = false">取 消</el-button>
        <el-button class="surebtn" @click="adminresetpwd()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { adminlogout, adminresetpwd } from "@/api/index";
// 导入组件

export default {
  components: {},
  data: function () {
    return {
      navBg: 0,
      indexShow: false,
      VideoShow: false,
      activeIndex: "1",
      activeIndex2: "1",
      videoset: false,
      account: localStorage.getItem("user") || "admin",
      elbreadcrumbitems: [],
      adddialogVisible: false,
      passwordForm: {
        confirmPassword: "",
        password: "",
      },
    };
  },
  computed: {
    key() {
      return this.$route.path;
    },
  },
  watch: {
    $route: {
      handler(val) {
        this.$nextTick(() => {
          setTimeout(() => {
            if (val.path == "/layout/index") {
              document.querySelector(".shouye").classList.add("is-active");
            } else {
              document.querySelector(".shouye").classList.remove("is-active");
            }
          }, 10);
        });
      },
      immediate: true,
    },
  },
  methods: {
    adminresetpwd() {
      if (this.passwordForm.confirmPassword !== this.passwordForm.password) {
        this.$message.error("两次密码输入不一致");
        return;
      }
      adminresetpwd(this.passwordForm).then((res) => {
        this.adddialogVisible = false;
        this.$message.success("修改成功");
      });
    },
    adminlogout() {
      adminlogout().then((res) => {
        this.$message.success("退出成功");
        localStorage.clear();
        this.$router.push({
          path: "/",
        });
      });
    },
    // hover事件
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
    },
    out() {
      this.adminlogout();
    },
    // homeShow(){
    // 	this.$router.push({
    // 		path:"/"
    // 	})
    // },

    // videolist(){
    // 	 console.log('222')
    // 	 this.videoset  = !this.videoset
    // }

    // videoVideo(){
    // 	this.$router.push({
    // 		path:"/videolist"
    // 	})
    // }
  },
  mounted() {
    this.videoset = false;
  },
};
</script>

<style lang="scss">
.nav-top {
  width: 100%;
  min-width: 1200px;
  display: flex;
  box-shadow: 0px 4px 10px 0px rgba(62, 57, 58, 0.2);
  position: relative;
  z-index: 2;
  background-color: #fff;
}

.nav-list {
  width: 100%;
  height: calc(100vh - 70px);
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding-top: 30px;
  box-sizing: border-box;
}

.el-menu.el-menu--horizontal {
  display: flex;
  /* justify-content: center; */
  border-bottom: solid 1px #e6e6e6;
}

.nav-logo {
  padding-left: 25px;
  height: 61px;
  padding-right: 26px;

  img {
    width: 192px;
    height: 32px;
  }
}

.nav-user {
  float: right;
}

.nav-user p {
  float: right;
}

.nav-login {
  margin-right: 35px;
  // width: 240px;
  display: flex;
  height: 60;
  background-color: #fff;
  color: #000;
}

.user {
  margin-right: 20px;
  margin-top: 17px;
}

.login-pic {
  margin-top: 14px;
  margin-right: 35px;
}

.login-out {
  margin-top: 17px;
  font-size: 15.5px;
}

.login-out a {
  text-decoration: none;
  color: #000;
}

/* .el-menu.el-menu--horizontal {
  padding-left: 314px;
} */
/* .isvideo {
	display: inline-block;
	padding-bottom: 20px;
	color: rgb(255, 208, 75);
	border-bottom: 2px solid rgb(255, 208, 75);
} */
</style>
<style scoped lang="scss">
.el-menu-demo {
  // position: absolute;
  // width: 300px;
  // height: 100vh;
  // top: 60px;
}
</style>
<style scoped lang="scss">
.lef {
  width: 200px;
  background-color: #fff;
  // height: calc(100vh - 61px);
}

.right {
  width: calc(100% - 200px);
  height: calc(100vh - 61px);
  overflow: auto;
  background: #f5f5f5;
  padding: 30px;
  box-sizing: border-box;
}

.el-menu {
  border: none;
}

.el-menu-item.is-active {
  background-color: #fff3f5;
  position: relative;
}

.el-menu-item:hover {
  background-color: #fff3f5;
}

.shouye .shouactive {
  display: none;
}

.shouye.is-active .shouactive {
  display: block;
}

.shouye.is-active .shouimg {
  display: none;
}

.shipin .shipinactive {
  display: none;
}

.shipin.is-active .shipinactive {
  display: block;
}

.shipin.is-active .shipinimg {
  display: none;
}

.yonghu .yonghuactive {
  display: none;
}

.yonghu.is-active .yonghuactive {
  display: block;
}

.yonghu.is-active .yonghuimg {
  display: none;
}

.shuju .shujuactive {
  display: none;
}

.shuju.is-active .shujuactive {
  display: block;
}

.shuju.is-active .shujuimg {
  display: none;
}

.xitong .xitongactive {
  display: none;
}

.xitong.is-active .xitongactive {
  display: block;
}

.xitong.is-active .xitongimg {
  display: none;
}

.el-menu-item.is-active::after {
  content: "";
  width: 4px;
  height: 56px;
  background-color: #ff5478;
  position: absolute;
  right: 0;
  top: 0;
}
</style>
